import { LEVEL_MAP } from '@/assets/constant/view.constants';
import { ComponentWithComputed } from 'miniprogram-computed';

ComponentWithComputed({
  properties: {
    /** 等级 */
    level: {
      type: String,
      value: '11',
    },
  },
  data: {
    /** 是否显示弹窗 */
    isShow: false,
  },
  computed: {
    /** 当前等级对应的图标和称号 */
    currentLevelInfo(data: typeof this.data) {
      return LEVEL_MAP.get(data.level);
    },
  },
  methods: {
    /** 显示弹窗 */
    open() {
      this.setData({
        isShow: true,
      });
    },
    /** 关闭弹窗 */
    close() {
      this.setData({
        isShow: false,
      });
    },
    onClose() {
      this.setData({
        isShow: false,
      });
    },
    /** 跳转到「升级奖励」页面 */
    jumpToLevelUpBonuses() {
      this.close();
      wx.navigateTo({
        url: '/subpkg/pages/level-up-bonuses/level-up-bonuses',
      });
    },
  },
});
